package GUI;

import game.Character;
import game.GameBase;
import game.TileMap;

public class Game {
	private static Game instance = null;
	
	private Character player = null;
	private TileMap map = null;
	private int turn = 0;
	
	public TileMap getMap() {
		return map;
	}

	public void setMap(TileMap map) {
		this.map = map;
	}

	public Character getPlayer() {
		return player;
	}

	public void setPlayer(Character player) {
		this.player = player;
	}
	
	public void initPlayer(String mapName)
	{
		if(player == null) return;
		
		map = GameBase.getMapByTag(mapName);
		if(map == null) { System.out.println("Starting map not found"); return; }
		
		//map.addCharacter(player, map.getpStartX(), map.getpStartY());
		map.addCharacter(player, map.getpStartX(), map.getpStartY());
	}

	private Game()
	{
		
	}
	
	public void passTurn()
	{
		if(this.map != null)
		{
			for(Character c : map.getCharacters())
			{
				c.GlobalTurnPassed();
			}
			turn++;
		}
	}
	
	public int getTurn()
	{
		return turn;
	}
	
	public static Game get()
	{
		if(instance == null) instance = new Game();
		return instance;
	}
}
